#include "backend/device/txda_device.h"

txdaError_t txdaModuleLoad(txdaModule_t* module, const char* file_path) {
  if (module == nullptr) {
    return txdaError_t::TXDA_ERROR;
  }

  if (file_path == nullptr) {
    return txdaError_t::TXDA_ERROR;
  }
  // TODO

  return txdaError_t::TXDA_SUCCESS;
}

txdaError_t txdaModuleUnload(txdaModule_t module) {
  // TODO
  return txdaError_t::TXDA_SUCCESS;
}

/* load module from code object which resides in host memory; data pointer to location */
txdaError_t txdaModuleLoadData(txdaModule_t* module, const void* data) {
  // TODO
  return txdaError_t::TXDA_SUCCESS;
}


txdaPathErrors_t txdaGetInstallPath(char** path, unsigned int* path_size) { // __attribute__((nonull))
  // TODO
  return txdaPathErrors_t::PathSuccess;
}

/************ End for TxDA header, should remove once TxDA ready ************/


#if TxDNN_OFFLINE_COMPILER_PATH_V280
static std::string generateCompilerPathValue(const char* relative_compiler_path) {
  char* txda_path = nullptr;
 
  std::string compiler_path_value;
  if (nullptr != relative_compiler_path) {
    txdaPathErrors_t ret = txdaGetInstallPath(&txda_path, &len);
    if (txdaPathErrors_t::PathSuccess == ret) {
      compiler_path_value = std::string(txda_path) + std::string(relative_compiler_path);
      free(txda_path);
    }
  }
  return compiler_path_value;
}

const char* getTxdaCompilerPath() {
  static const std::string path = generateCompilerPathValue(TXDNN_GCC_REL_PATH);
  return path.c_str;
}

#endif // TxDNN_OFFLINE_COMPILER_PATH_V280
